#pragma once
#include "StdAfx.h"
#include <vector>

#ifdef WIN32

#else

#endif

#define BASESCREENX 1280
#define BASESCREENY 720

enum
{
	_DONGKEY = 0,
};

class BGMaskHandler;

class UI_cl
{
public:
	UI_cl();
	~UI_cl();
	
	static UI_cl& GetInstance() { static UI_cl ui; return ui; }
	void Release();

	void SetUI();
	void Update(float fDelat);
	bool TouchPause(float x, float y);
	bool TouchStart( float x, float y );
	bool TouchFry( float x, float y );
	bool TouchCut( float x, float y );
	bool TouchTurn( float x, float y );
	bool TouchTent( float x, float y );
	bool TouchShop( float x, float y );
	bool TouchOtion( float x, float y );
	bool TouchRecipe( float x, float y );
	void SetCutBonusTimeUI();
	void SetStageResultUI();
	void SetTalkEventUI();
	void SetMainMenuUI();
	void SetTentUI();
	void SetLecipeUI();
	void SetShopUI();
	void SetOptionUI();

	void UpdateTime(float time);
	void UpdateScore(int score);
	void SetCutPlay();
	void SetFryPlay();
	void SetCutCombo(int combo, bool bcombo);

	void SetFryUI(bool visible);
	void SetVisibleMainMenu(BOOL visible);
	void SetVisibleInTent(BOOL visible);
	void SetVisivleLecipe(BOOL visible);
	void SetVisibleTalkEvent(BOOL visible, int state);
	void SetVisibleStageResult(BOOL visible, int score);
	void SetVisibleCutResult(BOOL visible);
	void SetVisibleTimeOver(BOOL visible);
	void SetVisibleCutBonusTime_Help(BOOL visible);
	void SetVisibleCutBonusTime(BOOL visible);

	hkvVec2 GetFryScrollButtonBase(){ return m_FryScrollButtonbase; }
	void SetFryScrollButtonPos(float x,float y){ m_spFryScrollButton->SetPos(m_FryScrollButtonbase.x, y); }
	void SetFryScrollButtonBasePos(){ m_spFryScrollButton->SetPos(m_FryScrollButtonbase.x, m_FryScrollButtonbase.y); }
	void SetCutBonusTime_Help(float BonusTime, float fDelta);
	void SetBonusTimePlay(float fDelta, bool bShake);

	bool GetIsPause(){ return m_bPause; }

	void ClearPlay();
	void ClearFryPlay();

	//scroll
	void SetScrollBackGround(float dx=0, float dy=0);
	void SetScrollBackGroundReset();
	void SetScrollBackGroundRestart();

private:
	float m_Ratio_x, m_Ratio_y;
	float m_Blank_x, m_Blank_y;
	int m_ScoreCipher;
	int m_ResultScoreCipher;
	int m_ComboCipher;

	VisScreenMaskPtr m_spPause;
	VRectanglef m_rPause;

	VisScreenMaskPtr m_spResume;
	VRectanglef m_rPlay;
	VRectanglef m_rBack;

	VisScreenMaskPtr m_spTime;
	VisScreenMaskPtr m_spTimeOver;

	VTextureObjectPtr m_tpComma;
	int m_CommaCheck;
	int m_CommaNum;
	int m_ResultCommaCheck;
	int m_ResultCommaNum;

	BGMaskHandler* m_maskHandler;

	//cut
	VisScreenMaskPtr m_spCutBackGround;

	//fry
	VisScreenMaskPtr m_spFryBackGround;
	VisScreenMaskPtr m_spFryScroll;
	VisScreenMaskPtr m_spFryScrollButton;
	hkvVec2 m_FryScrollButtonbase;

	VTextureObjectPtr m_tpNumber[10];
	//	std::vector <VisScreenMaskPtr> m_spScoreCipher;
	VisScreenMaskPtr m_spScoreCipher[13];
	VisScreenMaskPtr m_spTimeCipher[2];

	VisScreenMaskPtr m_spCombo;
	VTextureObjectPtr m_tpComboNumber[10];
	std::vector <VisScreenMaskPtr> m_spComboNumber;
	bool m_bCombo;
	float m_ComboTime;

	VisScreenMaskPtr m_spBonusTime;
	VTextureObjectPtr m_tpBonusTimeHelp[2];
	float m_BonusTime_Time;
	int m_BonusTimeHelp_ChageNum;

	VisScreenMaskPtr m_spBonusTimeHelp;
	VTextureObject* m_tpBonusTimeNum[3];
	VisScreenMaskPtr m_spBonusTimeNum;

	VisScreenMaskPtr m_spBonusShakeBG;
	VTextureObjectPtr m_tpBonusShakeBG[6];
	int m_iBonusShakeBG;

	VisScreenMaskPtr m_spBonusShakeCruet;
	VTextureObjectPtr m_tpBonusShakeCruet[2];
	int m_iBonusShakeCruet;

	VisScreenMaskPtr m_spScoreBorad;
	VisScreenMaskPtr m_spScoreStamp;
	VTextureObjectPtr m_tpScoreStamp[6];

	//	std::vector <VisScreenMaskPtr> m_spScoreBoradCipher;
	VisScreenMaskPtr m_spScoreBoradCipher[13];

	VisScreenMaskPtr m_spTalkEvent;
	VisScreenMaskPtr m_spStart;
	VRectanglef m_rStartIconRect;

	VisScreenMaskPtr m_spMainMenu;
	VisScreenMaskPtr m_spMainMenuTent;
	VisScreenMaskPtr m_spMainMenuShop;
	VisScreenMaskPtr m_spMainMenuOtion;
	VisScreenMaskPtr m_spInTent;
	VisScreenMaskPtr m_spVJLena;
	VisScreenMaskPtr m_spLecipeIcon;
	VisScreenMaskPtr m_spLecipe1;
	VisScreenMaskPtr m_spLecipe2;
	VisScreenMaskPtr m_spLecipe3;
	VisScreenMaskPtr m_spUDonkey;
	VisScreenMaskPtr m_spFry;
	VisScreenMaskPtr m_spCut;
	VisScreenMaskPtr m_spTrun;
	VRectanglef m_rFry;
	VRectanglef m_rCut;
	VRectanglef m_rTurn;
	VRectanglef m_rTent;
	VRectanglef m_rShop;
	VRectanglef m_rOtion;
	VRectanglef m_rVJLena;
	VRectanglef m_rRecipeIcon;
	VRectanglef m_rRecipe1;
	VRectanglef m_rRecipe2;
	VRectanglef m_rRecipe3;
	VRectanglef m_rUDonkey;

	VisScreenMaskPtr m_spTent;

	//scroll
	float m_TouchPosYDelta;
	float m_ScrollTextrueSideMmovePos;

	//mainmunu rect
	VRectanglef m_rMainMenuTent;
	VRectanglef m_rMainMenuShop;
	VRectanglef m_rMainMenuOtion;

	bool m_bPause;
};

class BGMaskHandler : public IVisCallbackHandler_cl
{
public:
	BGMaskHandler(VisScreenMaskPtr backGround = NULL)
	{
		m_BackGround = backGround;
		Vision::Callbacks.OnRenderHook += this;
	}

	~BGMaskHandler()
	{
		Vision::Callbacks.OnRenderHook -= this;
	}

	void SetTexture(VisScreenMaskPtr backGround)
	{
		m_BackGround = backGround;
	}

	void OnHandleCallback(IVisCallbackDataObject_cl *pData)
	{
		if(((VisRenderHookDataObject_cl *)pData)->m_iEntryConst==VIS_RENDERORDER_PRE_RENDERING)
		{
			VisScreenMaskCollection_cl collection(1,1);
			collection.AppendEntry(m_BackGround);
			Vision::RenderLoopHelper.RenderScreenMasks(collection);
		}
	}

private:
	VisScreenMaskPtr m_BackGround;
};

